package com.sgb.kjwl;


import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

import com.aliyun.vod.common.httpfinal.QupaiHttpFinal;
import com.im.immodel.IMUtils;
import com.mob.MobSDK;
import com.sgb.capital.utils.CapitalInit;
import com.sgb.contract.base.ContractSdk;
import com.sgb.goods.utils.base.GoodsSdk;
import com.sgb.goods.utils.module.GoodsModule;
import com.sgb.kjwl.aspectj.login.ILogin;
import com.sgb.kjwl.aspectj.login.LoginSDK;
import com.sgb.kjwl.model.api.ApiSourceImpl;
import com.sgb.kjwl.model.api.PreferenceSource;
import com.sgb.kjwl.view.ui.activity.self.authentication.CertificationActivity;
import com.sgb.kjwl.view.ui.activity.self.order.GoodsModuleComponent;
import com.sgb.link.router.PathLogin;
import com.sgb.link.utils.Preferences;
import com.swgk.core.BaseAppApplication;
import com.swgk.core.base.api.BaseApiSourceImpl;

import com.swgk.core.common.utils.ActivityJump;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.util.MLog;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.util.UiUtil;
import com.tencent.bugly.crashreport.CrashReport;

import cn.jpush.android.api.JPushInterface;

/**
 * Description:
 * Author zhengkewen
 */
public class AppApplication extends BaseAppApplication {
    private static final String DB_PATH = "sgb/db";
    private static final String BASE_URL = "https://api.shigongbang.com:9696/";


    @Override
    protected BaseApiSourceImpl getApiSoure() {
        return new ApiSourceImpl();
    }

    @Override
    protected String getBaseUrl() {
        return BASE_URL;
    }

    @Override
    protected String getDbPath() {
        return DB_PATH;
    }

    @Override
    protected <T> Class<T> getPreferenceSourceClass() {
        return (Class<T>) PreferenceSource.class;
    }

    @Override
    public void onCreate() {
        boolean isDebug = BuildConfig.BUILD_TYPE.equals("release") && !BuildConfig.DEBUG ? false : true;
        MLog.DEBUG_LOG = isDebug;
        MLog.isOnlin = BuildConfig.BUILD_TYPE.equals("release");
        super.onCreate();
        JPushInterface.setDebugMode(MLog.DEBUG_LOG);
        JPushInterface.init(this);

        //初始化 sp缓存工具
        SharedPreferenceUtil.init(this);

        UiUtil.init(this);

        //资金中心
        CapitalInit.init(this, BuildConfig.BUILD_TYPE);

        // 在线合同 ContractSdk 初始化
        ContractSdk.getInstance().init(getApplicationContext());

        // 商品材料 Module GoodsSdk 初始化
        GoodsSdk.getInstance().init(getApplicationContext());
        // 商品材料 Module 注册代理组件
        GoodsModule.getInstance().setDebug(true);
        GoodsModule.getInstance().registerComponent(GoodsModuleComponent.class);

        //bugly
        if (MLog.DEBUG_LOG) {
            CrashReport.initCrashReport(this, "260dbc8026", false);
        }

        //初始化用于显示商品详情的webView
        initWebView();

        //初始化小视频sdk
        QupaiHttpFinal.getInstance().initOkHttpFinal();

        MobSDK.init(this, "m30e97113ebbc9", "5a1868abcf2acf6237a4b7a5623d344c");

        //初始化IM配置
        IMUtils.getInstance().initContext(this);
        Preferences.setContext(this);

        //ARouter 初始化再启动器的 AppInitializer 中 CommonInitializer 中已经初始化了，此处不用再初始化
    }

    private void initWebView() {
        GoodsWebView.init(this);
    }

}
